from importlib.util import source_hash

list1 = ['Google', 'Runoob', 1997, 2000]
list2 = [1, 2, 3, 4, 5]
list3 = ["a", "b", "c", "d"]
list4 = ['red', 'green', 'blue', 'yellow', 'white', 'black']

# 倒叙
print(list1[::-1])
list1.reverse()
print(list1[0:1])
print(list1[0:-1])

# 取值
list_2 = list1[2:4]
print(list_2)
# 取值,索引2之后所有的
list_2 = list1[2:]
# 查询字段出现次数
print(list1.count('Runoob'))
# 查询字段索引
print(list1.index('Runoob'))

# 添加
list1.append('Runoob')
# 拼接
list4 = list4 + list4
print(list4)
list4 = list4.insert(3,'asd')
print(list4)

# 添加,作为属性
list1.append('Runoob')
list1.extend(list2)
print(list1)

# 更新
list2[0] = 'Google'
print(list2)

# 删除
del list3[0]
#清空
list5=[1,2]
list5.clear()
list6=[1,2]
list6.remove(1)
print("list2", list2)


# 长度
print(len(list1))

#校验参数是否存在属性
print('Runoob' in list1)


tinydict = {'Name': 'Runoob', 'Age': 7, 'Class': 'First'}
del tinydict["Name"]
print(tinydict)

# tuple： 元组，不可变的列表
a = (1, 2, 3)
print(a, type(a))

# dict: 字典，dictionary
#     key: value  : 键值对
a = {"name": 'ikun', "like": '篮球', "age": 22}
print(a, type(a))

# set: 集合（了解）,唯一
a = {1, 2, 3, 3, 3, 2, 2, 1}
print(a, type(a))  # {1, 2, 3} <class 'set'>


lst = ['a', 'b', 'c', 'd']
for i in range(len(lst)):
    print(i, lst[i])